﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using InSafetyAirServer.Database;


namespace InSafetyAirServer.Controller
{
    class PersonCtr
    {
        public static void createPerson(Person person)
        {
            SQLDatabaseDataContext _db = new SQLDatabaseDataContext();
            _db.Persons.InsertOnSubmit(person);
            _db.SubmitChanges();
        }

        public static void updatePerson(Person person)
        {
            SQLDatabaseDataContext _db = new SQLDatabaseDataContext();
            Person thePerson = _db.Persons.Single(p => p.personId == person.personId);
            if (thePerson != null)
            {
                Functions.getInstance().CopyProperties(thePerson, person);
                _db.SubmitChanges();
            }
        }
    }
}
